﻿namespace YourLastOptionsDialog.ViewModels.Options
{
    /// <summary>
    /// An option that is the base class for all floating point options.
    /// </summary>
    public abstract class FloatOptionBase : Option
    {
        private double _minimum = double.MinValue;

        private double _maximum = double.MaxValue;

        /// <summary>
        /// Gets or sets the minimum allowed value for this option.
        /// The default is <see cref="double.MinValue"/>.
        /// </summary>
        public double Minimum
        {
            get
            {
                return _minimum;
            }

            set
            {
                if (_minimum != value)
                {
                    _minimum = value;
                    RaisePropertyChanged("Minimum");
                }
            }
        }

        /// <summary>
        /// Gets or sets the maximum.
        /// The default is <see cref="double.MaxValue"/>.
        /// </summary>
        public double Maximum
        {
            get
            {
                return _maximum;
            }

            set
            {
                if (_maximum != value)
                {
                    _maximum = value;
                    RaisePropertyChanged("Maximum");
                }
            }
        }

        /// <summary>
        /// Gets or sets the validation error message that is used if the value is outside the configured 
        /// minimum or maximum bounds, or if the user enters a string that cannot be converted to a floating point value.
        /// </summary>
        public string ValidationErrorMessage
        {
            get
            {
                return Validator.ValidationErrorMessage;
            }

            set
            {
                Validator.ValidationErrorMessage = value;
            }
        }

        /// <summary>
        /// Gets the floating point value validator.
        /// </summary>
        public abstract FloatValidator Validator
        {
            get;
        }
    }
}